/**
 *
 * \section COPYRIGHT
 *
 * Copyright 2013-2015 Software Radio Systems Limited
 *
 * \section LICENSE
 *
 * This file is part of the srsLTE library.
 *
 * srsLTE is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of
 * the License, or (at your option) any later version.
 *
 * srsLTE is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * A copy of the GNU Affero General Public License can be found in
 * the LICENSE file in the top-level directory of this distribution
 * and at http://www.gnu.org/licenses/.
 *
 */

 #include "srslte/intf/intf.h"

const int tbs_format1c_table[32] = {
    40, 56, 72, 120, 136, 144, 176, 208, 224, 256, 280, 296, 328, 336, 392, 488,
    552, 600, 632, 696, 776, 840, 904, 1000, 1064, 1128, 1224, 1288, 1384, 1480, 1608, 1736
};

/* Modulation and TBS index table for PDSCH from 3GPP TS 36.213 v10.3.0 table 7.1.7.1-1 */
const int mcs_tbs_idx_table[29] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9,
                                    9, 10, 11, 12, 13, 14, 15, 15, 16, 17,
                                   18, 19, 20, 21, 22, 23, 24, 25, 26};


/* Transport Block Size from 3GPP TS 36.213 v10.3.0 table 7.1.7.2.1-1 */
const int tbs_table[27][110] = {{      16,   32,   56,   88,  120,  152,  176,  208,  224,  256,  288,
                                328,  344,  376,  392,  424,  456,  488,  504,  536,  568,  600,
                                616,  648,  680,  712,  744,  776,  776,  808,  840,  872,  904,
                                936,  968, 1000, 1032, 1032, 1064, 1096, 1128, 1160, 1192, 1224,
                               1256, 1256, 1288, 1320, 1352, 1384, 1416, 1416, 1480, 1480, 1544,
                               1544, 1608, 1608, 1608, 1672, 1672, 1736, 1736, 1800, 1800, 1800,
                               1864, 1864, 1928, 1928, 1992, 1992, 2024, 2088, 2088, 2088, 2152,
                               2152, 2216, 2216, 2280, 2280, 2280, 2344, 2344, 2408, 2408, 2472,
                               2472, 2536, 2536, 2536, 2600, 2600, 2664, 2664, 2728, 2728, 2728,
                               2792, 2792, 2856, 2856, 2856, 2984, 2984, 2984, 2984, 2984, 3112},
                             {   24,   56,   88,  144,  176,  208,  224,  256,  328,  344,  376,
                                424,  456,  488,  520,  568,  600,  632,  680,  712,  744,  776,
                                808,  872,  904,  936,  968, 1000, 1032, 1064, 1128, 1160, 1192,
                               1224, 1256, 1288, 1352, 1384, 1416, 1416, 1480, 1544, 1544, 1608,
                               1608, 1672, 1736, 1736, 1800, 1800, 1864, 1864, 1928, 1992, 1992,
                               2024, 2088, 2088, 2152, 2152, 2216, 2280, 2280, 2344, 2344, 2408,
                               2472, 2472, 2536, 2536, 2600, 2600, 2664, 2728, 2728, 2792, 2792,
                               2856, 2856, 2856, 2984, 2984, 2984, 3112, 3112, 3112, 3240, 3240,
                               3240, 3240, 3368, 3368, 3368, 3496, 3496, 3496, 3496, 3624, 3624,
                               3624, 3752, 3752, 3752, 3752, 3880, 3880, 3880, 4008, 4008, 4008},
                             {   32,   72,  144,  176,  208,  256,  296,  328,  376,  424,  472,
                                520,  568,  616,  648,  696,  744,  776,  840,  872,  936,  968,
                               1000, 1064, 1096, 1160, 1192, 1256, 1288, 1320, 1384, 1416, 1480,
                               1544, 1544, 1608, 1672, 1672, 1736, 1800, 1800, 1864, 1928, 1992,
                               2024, 2088, 2088, 2152, 2216, 2216, 2280, 2344, 2344, 2408, 2472,
                               2536, 2536, 2600, 2664, 2664, 2728, 2792, 2856, 2856, 2856, 2984,
                               2984, 3112, 3112, 3112, 3240, 3240, 3240, 3368, 3368, 3368, 3496,
                               3496, 3496, 3624, 3624, 3624, 3752, 3752, 3880, 3880, 3880, 4008,
                               4008, 4008, 4136, 4136, 4136, 4264, 4264, 4264, 4392, 4392, 4392,
                               4584, 4584, 4584, 4584, 4584, 4776, 4776, 4776, 4776, 4968, 4968},
                             {   40,  104,  176,  208,  256,  328,  392,  440,  504,  568,  616,
                                680,  744,  808,  872,  904,  968, 1032, 1096, 1160, 1224, 1256,
                               1320, 1384, 1416, 1480, 1544, 1608, 1672, 1736, 1800, 1864, 1928,
                               1992, 2024, 2088, 2152, 2216, 2280, 2344, 2408, 2472, 2536, 2536,
                               2600, 2664, 2728, 2792, 2856, 2856, 2984, 2984, 3112, 3112, 3240,
                               3240, 3368, 3368, 3496, 3496, 3624, 3624, 3624, 3752, 3752, 3880,
                               3880, 4008, 4008, 4136, 4136, 4264, 4264, 4392, 4392, 4392, 4584,
                               4584, 4584, 4776, 4776, 4776, 4776, 4968, 4968, 4968, 5160, 5160,
                               5160, 5352, 5352, 5352, 5352, 5544, 5544, 5544, 5736, 5736, 5736,
                               5736, 5992, 5992, 5992, 5992, 6200, 6200, 6200, 6200, 6456, 6456},
                             {   56,  120,  208,  256,  328,  408,  488,  552,  632,  696,  776,
                                840,  904, 1000, 1064, 1128, 1192, 1288, 1352, 1416, 1480, 1544,
                               1608, 1736, 1800, 1864, 1928, 1992, 2088, 2152, 2216, 2280, 2344,
                               2408, 2472, 2600, 2664, 2728, 2792, 2856, 2984, 2984, 3112, 3112,
                               3240, 3240, 3368, 3496, 3496, 3624, 3624, 3752, 3752, 3880, 4008,
                               4008, 4136, 4136, 4264, 4264, 4392, 4392, 4584, 4584, 4584, 4776,
                               4776, 4968, 4968, 4968, 5160, 5160, 5160, 5352, 5352, 5544, 5544,
                               5544, 5736, 5736, 5736, 5992, 5992, 5992, 5992, 6200, 6200, 6200,
                               6456, 6456, 6456, 6456, 6712, 6712, 6712, 6968, 6968, 6968, 6968,
                               7224, 7224, 7224, 7480, 7480, 7480, 7480, 7736, 7736, 7736, 7992},
                             {   72,  144,  224,  328,  424,  504,  600,  680,  776,  872,  968,
                               1032, 1128, 1224, 1320, 1384, 1480, 1544, 1672, 1736, 1864, 1928,
                               2024, 2088, 2216, 2280, 2344, 2472, 2536, 2664, 2728, 2792, 2856,
                               2984, 3112, 3112, 3240, 3368, 3496, 3496, 3624, 3752, 3752, 3880,
                               4008, 4008, 4136, 4264, 4392, 4392, 4584, 4584, 4776, 4776, 4776,
                               4968, 4968, 5160, 5160, 5352, 5352, 5544, 5544, 5736, 5736, 5736,
                               5992, 5992, 5992, 6200, 6200, 6200, 6456, 6456, 6712, 6712, 6712,
                               6968, 6968, 6968, 7224, 7224, 7224, 7480, 7480, 7480, 7736, 7736,
                               7736, 7992, 7992, 7992, 8248, 8248, 8248, 8504, 8504, 8760, 8760,
                               8760, 8760, 9144, 9144, 9144, 9144, 9528, 9528, 9528, 9528, 9528},
                             {  328,  176,  256,  392,  504,  600,  712,  808,  936, 1032, 1128,
                               1224, 1352, 1480, 1544, 1672, 1736, 1864, 1992, 2088, 2216, 2280,
                               2408, 2472, 2600, 2728, 2792, 2984, 2984, 3112, 3240, 3368, 3496,
                               3496, 3624, 3752, 3880, 4008, 4136, 4136, 4264, 4392, 4584, 4584,
                               4776, 4776, 4968, 4968, 5160, 5160, 5352, 5352, 5544, 5736, 5736,
                               5992, 5992, 5992, 6200, 6200, 6456, 6456, 6456, 6712, 6712, 6968,
                               6968, 6968, 7224, 7224, 7480, 7480, 7736, 7736, 7736, 7992, 7992,
                               8248, 8248, 8248, 8504, 8504, 8760, 8760, 8760, 9144, 9144, 9144,
                               9144, 9528, 9528, 9528, 9528, 9912, 9912, 9912,10296,10296,10296,
                              10296,10680,10680,10680,10680,11064,11064,11064,11448,11448,11448},
                             {  104,  224,  328,  472,  584,  712,  840,  968, 1096, 1224, 1320,
                               1480, 1608, 1672, 1800, 1928, 2088, 2216, 2344, 2472, 2536, 2664,
                               2792, 2984, 3112, 3240, 3368, 3368, 3496, 3624, 3752, 3880, 4008,
                               4136, 4264, 4392, 4584, 4584, 4776, 4968, 4968, 5160, 5352, 5352,
                               5544, 5736, 5736, 5992, 5992, 6200, 6200, 6456, 6456, 6712, 6712,
                               6712, 6968, 6968, 7224, 7224, 7480, 7480, 7736, 7736, 7992, 7992,
                               8248, 8248, 8504, 8504, 8760, 8760, 8760, 9144, 9144, 9144, 9528,
                               9528, 9528, 9912, 9912, 9912,10296,10296,10296,10680,10680,10680,
                              11064,11064,11064,11448,11448,11448,11448,11832,11832,11832,12216,
                              12216,12216,12576,12576,12576,12960,12960,12960,12960,13536,13536},
                             {  120,  256,  392,  536,  680,  808,  968, 1096, 1256, 1384, 1544,
                               1672, 1800, 1928, 2088, 2216, 2344, 2536, 2664, 2792, 2984, 3112,
                               3240, 3368, 3496, 3624, 3752, 3880, 4008, 4264, 4392, 4584, 4584,
                               4776, 4968, 4968, 5160, 5352, 5544, 5544, 5736, 5992, 5992, 6200,
                               6200, 6456, 6456, 6712, 6968, 6968, 7224, 7224, 7480, 7480, 7736,
                               7736, 7992, 7992, 8248, 8504, 8504, 8760, 8760, 9144, 9144, 9144,
                               9528, 9528, 9528, 9912, 9912, 9912,10296,10296,10680,10680,10680,
                              11064,11064,11064,11448,11448,11448,11832,11832,12216,12216,12216,
                              12576,12576,12576,12960,12960,12960,13536,13536,13536,13536,14112,
                              14112,14112,14112,14688,14688,14688,14688,15264,15264,15264,15264},
                             {  136,  296,  456,  616,  776,  936, 1096, 1256, 1416, 1544, 1736,
                               1864, 2024, 2216, 2344, 2536, 2664, 2856, 2984, 3112, 3368, 3496,
                               3624, 3752, 4008, 4136, 4264, 4392, 4584, 4776, 4968, 5160, 5160,
                               5352, 5544, 5736, 5736, 5992, 6200, 6200, 6456, 6712, 6712, 6968,
                               6968, 7224, 7480, 7480, 7736, 7992, 7992, 8248, 8248, 8504, 8760,
                               8760, 9144, 9144, 9144, 9528, 9528, 9912, 9912,10296,10296,10296,
                              10680,10680,11064,11064,11064,11448,11448,11832,11832,11832,12216,
                              12216,12576,12576,12960,12960,12960,13536,13536,13536,13536,14112,
                              14112,14112,14112,14688,14688,14688,15264,15264,15264,15264,15840,
                              15840,15840,16416,16416,16416,16416,16992,16992,16992,16992,17568},
                             {  144,  328,  504,  680,  872, 1032, 1224, 1384, 1544, 1736, 1928,
                               2088, 2280, 2472, 2664, 2792, 2984, 3112, 3368, 3496, 3752, 3880,
                               4008, 4264, 4392, 4584, 4776, 4968, 5160, 5352, 5544, 5736, 5736,
                               5992, 6200, 6200, 6456, 6712, 6712, 6968, 7224, 7480, 7480, 7736,
                               7992, 7992, 8248, 8504, 8504, 8760, 9144, 9144, 9144, 9528, 9528,
                               9912, 9912,10296,10296,10680,10680,11064,11064,11448,11448,11448,
                              11832,11832,12216,12216,12576,12576,12960,12960,12960,13536,13536,
                              13536,14112,14112,14112,14688,14688,14688,14688,15264,15264,15264,
                              15840,15840,15840,16416,16416,16416,16992,16992,16992,16992,17568,
                              17568,17568,18336,18336,18336,18336,18336,19080,19080,19080,19080},
                             {  176,  376,  584,  776, 1000, 1192, 1384, 1608, 1800, 2024, 2216,
                               2408, 2600, 2792, 2984, 3240, 3496, 3624, 3880, 4008, 4264, 4392,
                               4584, 4776, 4968, 5352, 5544, 5736, 5992, 5992, 6200, 6456, 6712,
                               6968, 6968, 7224, 7480, 7736, 7736, 7992, 8248, 8504, 8760, 8760,
                               9144, 9144, 9528, 9528, 9912, 9912,10296,10680,10680,11064,11064,
                              11448,11448,11832,11832,12216,12216,12576,12576,12960,12960,13536,
                              13536,13536,14112,14112,14112,14688,14688,14688,15264,15264,15840,
                              15840,15840,16416,16416,16416,16992,16992,16992,17568,17568,17568,
                              18336,18336,18336,18336,19080,19080,19080,19080,19848,19848,19848,
                              19848,20616,20616,20616,21384,21384,21384,21384,22152,22152,22152},
                             {  208,  440,  680,  904, 1128, 1352, 1608, 1800, 2024, 2280, 2472,
                               2728, 2984, 3240, 3368, 3624, 3880, 4136, 4392, 4584, 4776, 4968,
                               5352, 5544, 5736, 5992, 6200, 6456, 6712, 6712, 6968, 7224, 7480,
                               7736, 7992, 8248, 8504, 8760, 8760, 9144, 9528, 9528, 9912, 9912,
                              10296,10680,10680,11064,11064,11448,11832,11832,12216,12216,12576,
                              12576,12960,12960,13536,13536,14112,14112,14112,14688,14688,15264,
                              15264,15264,15840,15840,16416,16416,16416,16992,16992,17568,17568,
                              17568,18336,18336,18336,19080,19080,19080,19080,19848,19848,19848,
                              20616,20616,20616,21384,21384,21384,21384,22152,22152,22152,22920,
                              22920,22920,23688,23688,23688,23688,24496,24496,24496,24496,25456},
                             {  224,  488,  744, 1000, 1256, 1544, 1800, 2024, 2280, 2536, 2856,
                               3112, 3368, 3624, 3880, 4136, 4392, 4584, 4968, 5160, 5352, 5736,
                               5992, 6200, 6456, 6712, 6968, 7224, 7480, 7736, 7992, 8248, 8504,
                               8760, 9144, 9144, 9528, 9912, 9912,10296,10680,10680,11064,11448,
                              11448,11832,12216,12216,12576,12960,12960,13536,13536,14112,14112,
                              14688,14688,14688,15264,15264,15840,15840,16416,16416,16992,16992,
                              16992,17568,17568,18336,18336,18336,19080,19080,19080,19848,19848,
                              19848,20616,20616,20616,21384,21384,21384,22152,22152,22152,22920,
                              22920,22920,23688,23688,23688,24496,24496,24496,25456,25456,25456,
                              25456,26416,26416,26416,26416,27376,27376,27376,27376,28336,28336},
                             {  256,  552,  840, 1128, 1416, 1736, 1992, 2280, 2600, 2856, 3112,
                               3496, 3752, 4008, 4264, 4584, 4968, 5160, 5544, 5736, 5992, 6200,
                               6456, 6968, 7224, 7480, 7736, 7992, 8248, 8504, 8760, 9144, 9528,
                               9912, 9912,10296,10680,11064,11064,11448,11832,12216,12216,12576,
                              12960,12960,13536,13536,14112,14112,14688,14688,15264,15264,15840,
                              15840,16416,16416,16992,16992,17568,17568,18336,18336,18336,19080,
                              19080,19848,19848,19848,20616,20616,20616,21384,21384,22152,22152,
                              22152,22920,22920,22920,23688,23688,24496,24496,24496,25456,25456,
                              25456,25456,26416,26416,26416,27376,27376,27376,28336,28336,28336,
                              28336,29296,29296,29296,29296,30576,30576,30576,30576,31704,31704},
                             {  280,  600,  904, 1224, 1544, 1800, 2152, 2472, 2728, 3112, 3368,
                               3624, 4008, 4264, 4584, 4968, 5160, 5544, 5736, 6200, 6456, 6712,
                               6968, 7224, 7736, 7992, 8248, 8504, 8760, 9144, 9528, 9912,10296,
                              10296,10680,11064,11448,11832,11832,12216,12576,12960,12960,13536,
                              13536,14112,14688,14688,15264,15264,15840,15840,16416,16416,16992,
                              16992,17568,17568,18336,18336,18336,19080,19080,19848,19848,20616,
                              20616,20616,21384,21384,22152,22152,22152,22920,22920,23688,23688,
                              23688,24496,24496,24496,25456,25456,25456,26416,26416,26416,27376,
                              27376,27376,28336,28336,28336,29296,29296,29296,29296,30576,30576,
                              30576,30576,31704,31704,31704,31704,32856,32856,32856,34008,34008},
                             {  328,  632,  968, 1288, 1608, 1928, 2280, 2600, 2984, 3240, 3624,
                               3880, 4264, 4584, 4968, 5160, 5544, 5992, 6200, 6456, 6712, 7224,
                               7480, 7736, 7992, 8504, 8760, 9144, 9528, 9912, 9912,10296,10680,
                              11064,11448,11832,12216,12216,12576,12960,13536,13536,14112,14112,
                              14688,14688,15264,15840,15840,16416,16416,16992,16992,17568,17568,
                              18336,18336,19080,19080,19848,19848,19848,20616,20616,21384,21384,
                              22152,22152,22152,22920,22920,23688,23688,24496,24496,24496,25456,
                              25456,25456,26416,26416,26416,27376,27376,27376,28336,28336,28336,
                              29296,29296,29296,30576,30576,30576,30576,31704,31704,31704,31704,
                              32856,32856,32856,34008,34008,34008,34008,35160,35160,35160,35160},
                             {  336,  696, 1064, 1416, 1800, 2152, 2536, 2856, 3240, 3624, 4008,
                               4392, 4776, 5160, 5352, 5736, 6200, 6456, 6712, 7224, 7480, 7992,
                               8248, 8760, 9144, 9528, 9912,10296,10296,10680,11064,11448,11832,
                              12216,12576,12960,13536,13536,14112,14688,14688,15264,15264,15840,
                              16416,16416,16992,17568,17568,18336,18336,19080,19080,19848,19848,
                              20616,20616,20616,21384,21384,22152,22152,22920,22920,23688,23688,
                              24496,24496,24496,25456,25456,26416,26416,26416,27376,27376,27376,
                              28336,28336,29296,29296,29296,30576,30576,30576,30576,31704,31704,
                              31704,32856,32856,32856,34008,34008,34008,35160,35160,35160,35160,
                              36696,36696,36696,36696,37888,37888,37888,39232,39232,39232,39232},
                             {  376,  776, 1160, 1544, 1992, 2344, 2792, 3112, 3624, 4008, 4392,
                               4776, 5160, 5544, 5992, 6200, 6712, 7224, 7480, 7992, 8248, 8760,
                               9144, 9528, 9912,10296,10680,11064,11448,11832,12216,12576,12960,
                              13536,14112,14112,14688,15264,15264,15840,16416,16416,16992,17568,
                              17568,18336,18336,19080,19080,19848,19848,20616,21384,21384,22152,
                              22152,22920,22920,23688,23688,24496,24496,24496,25456,25456,26416,
                              26416,27376,27376,27376,28336,28336,29296,29296,29296,30576,30576,
                              30576,31704,31704,31704,32856,32856,32856,34008,34008,34008,35160,
                              35160,35160,36696,36696,36696,37888,37888,37888,37888,39232,39232,
                              39232,40576,40576,40576,40576,42368,42368,42368,42368,43816,43816},
                             {  408,  840, 1288, 1736, 2152, 2600, 2984, 3496, 3880, 4264, 4776,
                               5160, 5544, 5992, 6456, 6968, 7224, 7736, 8248, 8504, 9144, 9528,
                               9912,10296,10680,11064,11448,12216,12576,12960,13536,13536,14112,
                              14688,15264,15264,15840,16416,16992,16992,17568,18336,18336,19080,
                              19080,19848,20616,20616,21384,21384,22152,22152,22920,22920,23688,
                              24496,24496,25456,25456,25456,26416,26416,27376,27376,28336,28336,
                              29296,29296,29296,30576,30576,30576,31704,31704,32856,32856,32856,
                              34008,34008,34008,35160,35160,35160,36696,36696,36696,37888,37888,
                              37888,39232,39232,39232,40576,40576,40576,40576,42368,42368,42368,
                              43816,43816,43816,43816,45352,45352,45352,46888,46888,46888,46888},
                             {  440,  904, 1384, 1864, 2344, 2792, 3240, 3752, 4136, 4584, 5160,
                               5544, 5992, 6456, 6968, 7480, 7992, 8248, 8760, 9144, 9912,10296,
                              10680,11064,11448,12216,12576,12960,13536,14112,14688,14688,15264,
                              15840,16416,16992,16992,17568,18336,18336,19080,19848,19848,20616,
                              20616,21384,22152,22152,22920,22920,23688,24496,24496,25456,25456,
                              26416,26416,27376,27376,28336,28336,29296,29296,29296,30576,30576,
                              31704,31704,31704,32856,32856,34008,34008,34008,35160,35160,35160,
                              36696,36696,36696,37888,37888,39232,39232,39232,40576,40576,40576,
                              42368,42368,42368,42368,43816,43816,43816,45352,45352,45352,46888,
                              46888,46888,46888,48936,48936,48936,48936,48936,51024,51024,51024},
                             {  488, 1000, 1480, 1992, 2472, 2984, 3496, 4008, 4584, 4968, 5544,
                               5992, 6456, 6968, 7480, 7992, 8504, 9144, 9528, 9912,10680,11064,
                              11448,12216,12576,12960,13536,14112,14688,15264,15840,15840,16416,
                              16992,17568,18336,18336,19080,19848,19848,20616,21384,21384,22152,
                              22920,22920,23688,24496,24496,25456,25456,26416,26416,27376,27376,
                              28336,28336,29296,29296,30576,30576,31704,31704,31704,32856,32856,
                              34008,34008,35160,35160,35160,36696,36696,36696,37888,37888,39232,
                              39232,39232,40576,40576,40576,42368,42368,42368,43816,43816,43816,
                              45352,45352,45352,46888,46888,46888,46888,48936,48936,48936,48936,
                              51024,51024,51024,51024,52752,52752,52752,52752,55056,55056,55056},
                             {  520, 1064, 1608, 2152, 2664, 3240, 3752, 4264, 4776, 5352, 5992,
                               6456, 6968, 7480, 7992, 8504, 9144, 9528,10296,10680,11448,11832,
                              12576,12960,13536,14112,14688,15264,15840,16416,16992,16992,17568,
                              18336,19080,19080,19848,20616,21384,21384,22152,22920,22920,23688,
                              24496,24496,25456,25456,26416,27376,27376,28336,28336,29296,29296,
                              30576,30576,31704,31704,32856,32856,34008,34008,34008,35160,35160,
                              36696,36696,36696,37888,37888,39232,39232,40576,40576,40576,42368,
                              42368,42368,43816,43816,43816,45352,45352,45352,46888,46888,46888,
                              48936,48936,48936,48936,51024,51024,51024,51024,52752,52752,52752,
                              55056,55056,55056,55056,57336,57336,57336,57336,59256,59256,59256},
                             {  552, 1128, 1736, 2280, 2856, 3496, 4008, 4584, 5160, 5736, 6200,
                               6968, 7480, 7992, 8504, 9144, 9912,10296,11064,11448,12216,12576,
                              12960,13536,14112,14688,15264,15840,16416,16992,17568,18336,19080,
                              19848,19848,20616,21384,22152,22152,22920,23688,24496,24496,25456,
                              25456,26416,27376,27376,28336,28336,29296,29296,30576,30576,31704,
                              31704,32856,32856,34008,34008,35160,35160,36696,36696,37888,37888,
                              37888,39232,39232,40576,40576,40576,42368,42368,43816,43816,43816,
                              45352,45352,45352,46888,46888,46888,48936,48936,48936,51024,51024,
                              51024,51024,52752,52752,52752,55056,55056,55056,55056,57336,57336,
                              57336,57336,59256,59256,59256,59256,61664,61664,61664,61664,63776},
                             {  584, 1192, 1800, 2408, 2984, 3624, 4264, 4968, 5544, 5992, 6712,
                               7224, 7992, 8504, 9144, 9912,10296,11064,11448,12216,12960,13536,
                              14112,14688,15264,15840,16416,16992,17568,18336,19080,19848,19848,
                              20616,21384,22152,22920,22920,23688,24496,25456,25456,26416,26416,
                              27376,28336,28336,29296,29296,30576,31704,31704,32856,32856,34008,
                              34008,35160,35160,36696,36696,36696,37888,37888,39232,39232,40576,
                              40576,42368,42368,42368,43816,43816,45352,45352,45352,46888,46888,
                              46888,48936,48936,48936,51024,51024,51024,52752,52752,52752,52752,
                              55056,55056,55056,57336,57336,57336,57336,59256,59256,59256,61664,
                              61664,61664,61664,63776,63776,63776,63776,66592,66592,66592,66592},
                             {  616, 1256, 1864, 2536, 3112, 3752, 4392, 5160, 5736, 6200, 6968,
                               7480, 8248, 8760, 9528,10296,10680,11448,12216,12576,13536,14112,
                              14688,15264,15840,16416,16992,17568,18336,19080,19848,20616,20616,
                              21384,22152,22920,23688,24496,24496,25456,26416,26416,27376,28336,
                              28336,29296,29296,30576,31704,31704,32856,32856,34008,34008,35160,
                              35160,36696,36696,37888,37888,39232,39232,40576,40576,40576,42368,
                              42368,43816,43816,43816,45352,45352,46888,46888,46888,48936,48936,
                              48936,51024,51024,51024,52752,52752,52752,55056,55056,55056,55056,
                              57336,57336,57336,59256,59256,59256,61664,61664,61664,61664,63776,
                              63776,63776,63776,66592,66592,66592,66592,68808,68808,68808,71112},
                             {  712, 1480, 2216, 2984, 3752, 4392, 5160, 5992, 6712, 7480, 8248,
                               8760, 9528,10296,11064,11832,12576,13536,14112,14688,15264,16416,
                              16992,17568,18336,19080,19848,20616,21384,22152,22920,23688,24496,
                              25456,25456,26416,27376,28336,29296,29296,30576,30576,31704,32856,
                              32856,34008,35160,35160,36696,36696,37888,37888,39232,40576,40576,
                              40576,42368,42368,43816,43816,45352,45352,46888,46888,48936,48936,
                              48936,51024,51024,52752,52752,52752,55056,55056,55056,55056,57336,
                              57336,57336,59256,59256,59256,61664,61664,61664,63776,63776,63776,
                              66592,66592,66592,68808,68808,68808,71112,71112,71112,73712,73712,
                              75376,75376,75376,75376,75376,75376,75376,75376,75376,75376,75376}};

// TB size table with new harvested sizes.
const int tbs_table_scatter[27][110] = {{   16,   32,   56,   88,  120,  168,  200,  232,  256,  264,  296,  344,  360,  392,  408,  440,  480,  520,  536,  568,  600,  632,  648,  680,  728,  760,  792,  824,  824,  856,  888,  920,  952, 1000, 1032, 1064, 1096, 1096, 1128, 1160, 1192, 1256, 1288, 1320, 1352, 1352, 1384, 1416, 1448, 1480, 1512, 1512, 1576, 1576, 1640, 1640, 1704, 1704, 1704, 1800, 1800, 1864, 1864, 1928, 1928, 1928, 1992, 1992, 2088, 2088, 2152, 2152, 2152, 2216, 2216, 2216, 2344, 2344, 2408, 2408, 2472, 2472, 2472, 2536, 2536, 2600, 2600, 2664, 2664, 2728, 2728, 2728, 2792, 2792, 2856, 2856, 2920, 2920, 2920, 2984, 2984, 3048, 3048, 3048, 3176, 3176, 3176, 3176, 3176, 3368},
								{   24,   56,   88,  144,  176,  232,  248,  288,  368,  352,  392,  440,  472,  504,  552,  600,  632,  664,  712,  744,  792,  824,  856,  920,  952,  984, 1032, 1064, 1096, 1128, 1192, 1224, 1256, 1320, 1352, 1384, 1448, 1480, 1512, 1512, 1576, 1640, 1640, 1704, 1704, 1768, 1864, 1864, 1928, 1928, 1992, 1992, 2088, 2152, 2152, 2152, 2216, 2216, 2280, 2280, 2408, 2472, 2472, 2536, 2536, 2600, 2664, 2664, 2728, 2728, 2792, 2792, 2856, 2920, 2920, 2984, 2984, 3048, 3048, 3048, 3176, 3176, 3176, 3304, 3304, 3304, 3496, 3496, 3496, 3496, 3624, 3624, 3624, 3752, 3752, 3752, 3752, 3880, 3880, 3880, 4008, 4008, 4008, 4008, 4136, 4136, 4136, 4264, 4264, 4264},
								{   32,   72,  144,  176,  208,  280,  328,  368,  424,  432,  488,  536,  600,  648,  680,  728,  776,  808,  888,  920,  984, 1032, 1064, 1128, 1160, 1224, 1256, 1320, 1384, 1416, 1480, 1512, 1576, 1640, 1640, 1704, 1768, 1768, 1832, 1928, 1928, 1992, 2088, 2152, 2152, 2216, 2216, 2280, 2344, 2344, 2472, 2536, 2536, 2600, 2664, 2728, 2728, 2792, 2856, 2856, 2920, 2984, 3048, 3048, 3048, 3176, 3176, 3304, 3304, 3304, 3496, 3496, 3496, 3624, 3624, 3624, 3752, 3752, 3752, 3880, 3880, 3880, 4008, 4008, 4136, 4136, 4136, 4264, 4264, 4264, 4392, 4392, 4456, 4584, 4584, 4584, 4712, 4712, 4712, 4904, 4904, 4904, 4904, 4904, 5096, 5096, 5096, 5096, 5288, 5288},
								{   40,  104,  176,  208,  256,  360,  432,  488,  568,  584,  632,  712,  776,  840,  904,  952, 1032, 1096, 1160, 1224, 1288, 1320, 1384, 1480, 1512, 1576, 1640, 1704, 1768, 1832, 1896, 1992, 2088, 2152, 2152, 2216, 2280, 2344, 2408, 2536, 2600, 2664, 2728, 2728, 2792, 2856, 2920, 2984, 3048, 3048, 3176, 3176, 3304, 3304, 3432, 3432, 3624, 3624, 3752, 3752, 3880, 3880, 3880, 4008, 4008, 4136, 4136, 4264, 4264, 4392, 4392, 4584, 4584, 4712, 4712, 4712, 4904, 4904, 4904, 5096, 5096, 5096, 5096, 5288, 5288, 5288, 5480, 5480, 5480, 5736, 5736, 5736, 5736, 5928, 5928, 5928, 6120, 6120, 6120, 6120, 6456, 6456, 6456, 6456, 6712, 6712, 6712, 6712, 6968, 6968},
								{   56,  120,  208,  256,  328,  448,  536,  616,  712,  712,  808,  872,  936, 1064, 1128, 1192, 1256, 1352, 1416, 1480, 1576, 1640, 1704, 1832, 1896, 1960, 2088, 2152, 2216, 2280, 2344, 2408, 2472, 2600, 2664, 2792, 2856, 2920, 2984, 3048, 3176, 3176, 3304, 3304, 3432, 3432, 3624, 3752, 3752, 3880, 3880, 4008, 4008, 4136, 4264, 4264, 4392, 4392, 4520, 4520, 4712, 4712, 4904, 4904, 4904, 5096, 5096, 5288, 5288, 5288, 5480, 5480, 5480, 5736, 5736, 5928, 5928, 5928, 6120, 6120, 6120, 6456, 6456, 6456, 6456, 6584, 6584, 6584, 6968, 6968, 6968, 6968, 7224, 7224, 7224, 7480, 7480, 7480, 7480, 7736, 7736, 7736, 7992, 7992, 7992, 7992, 8248, 8248, 8248, 8504},
								{   72,  144,  224,  328,  424,  552,  664,  760,  872,  904, 1000, 1064, 1192, 1288, 1384, 1448, 1544, 1640, 1768, 1832, 1960, 2024, 2152, 2216, 2344, 2408, 2472, 2600, 2728, 2856, 2920, 2984, 3048, 3176, 3304, 3304, 3432, 3560, 3752, 3752, 3880, 4008, 4008, 4136, 4264, 4264, 4392, 4520, 4648, 4648, 4904, 4904, 5096, 5096, 5096, 5288, 5288, 5480, 5480, 5672, 5672, 5928, 5928, 6120, 6120, 6120, 6456, 6456, 6456, 6584, 6584, 6584, 6968, 6968, 7224, 7224, 7224, 7480, 7480, 7480, 7736, 7736, 7736, 7992, 7992, 7992, 8248, 8248, 8248, 8504, 8504, 8504, 8760, 8760, 8888, 9144, 9144, 9400, 9400, 9400, 9400, 9784, 9784, 9784, 9784,10168,10168,10168,10168,10168},
								{  328,  176,  256,  392,  504,  664,  792,  904, 1064, 1064, 1160, 1288, 1416, 1544, 1608, 1768, 1832, 1960, 2088, 2216, 2344, 2408, 2536, 2600, 2728, 2920, 2984, 3176, 3176, 3304, 3432, 3560, 3688, 3688, 3880, 4008, 4136, 4264, 4392, 4392, 4520, 4648, 4904, 4904, 5096, 5096, 5288, 5288, 5480, 5480, 5672, 5672, 5928, 6120, 6120, 6456, 6456, 6456, 6584, 6584, 6968, 6968, 6968, 7224, 7224, 7480, 7480, 7480, 7736, 7736, 7992, 7992, 8248, 8248, 8248, 8504, 8504, 8760, 8760, 8760, 9144, 9144, 9400, 9400, 9400, 9784, 9784, 9784, 9784,10168,10168,10168,10168,10552,10552,10552,11064,11064,11064,11064,11448,11448,11448,11448,11832,11832,11832,12216,12216,12216},
								{  104,  224,  328,  472,  584,  776,  936, 1096, 1224, 1256, 1384, 1544, 1672, 1736, 1896, 2024, 2216, 2344, 2472, 2600, 2664, 2792, 2984, 3176, 3304, 3432, 3560, 3560, 3688, 3816, 4008, 4136, 4264, 4392, 4520, 4648, 4840, 4840, 5096, 5288, 5288, 5480, 5672, 5672, 5864, 6120, 6120, 6456, 6456, 6584, 6584, 6840, 6840, 7224, 7224, 7224, 7480, 7480, 7736, 7736, 7992, 7992, 8248, 8248, 8504, 8504, 8760, 8760, 9144, 9144, 9400, 9400, 9400, 9784, 9784, 9784,10168,10168,10168,10552,10552,10552,10936,10936,10936,11448,11448,11448,11832,11832,11832,12216,12216,12216,12216,12576,12576,12576,13152,13152,13152,13536,13536,13536,13920,13920,13920,13920,14496,14496},
								{  120,  256,  392,  536,  680,  888, 1064, 1224, 1416, 1416, 1608, 1736, 1864, 2024, 2216, 2344, 2472, 2664, 2792, 2920, 3176, 3304, 3432, 3560, 3688, 3816, 3944, 4136, 4264, 4520, 4648, 4840, 4840, 5096, 5288, 5288, 5480, 5672, 5864, 5864, 6120, 6456, 6456, 6584, 6584, 6840, 6840, 7224, 7480, 7480, 7736, 7736, 7992, 7992, 8248, 8248, 8504, 8504, 8760, 9016, 9016, 9400, 9400, 9784, 9784, 9784,10168,10168,10168,10552,10552,10552,10936,10936,11448,11448,11448,11832,11832,11832,12216,12216,12216,12576,12576,13152,13152,13152,13536,13536,13536,13920,13920,13920,14496,14496,14496,14496,15072,15072,15072,15072,15648,15648,15648,15648,16224,16224,16224,16224},
								{  136,  296,  456,  616,  776, 1032, 1224, 1416, 1608, 1576, 1800, 1928, 2152, 2344, 2472, 2664, 2792, 2984, 3176, 3304, 3560, 3688, 3816, 3944, 4264, 4392, 4520, 4648, 4840, 5032, 5288, 5480, 5480, 5672, 5864, 6056, 6056, 6328, 6584, 6584, 6840, 7096, 7096, 7480, 7480, 7736, 7992, 7992, 8248, 8504, 8504, 8760, 8760, 9016, 9400, 9400, 9784, 9784, 9784,10168,10168,10552,10552,10936,10936,10936,11448,11448,11832,11832,11832,12216,12216,12576,12576,12576,13152,13152,13536,13536,13920,13920,13920,14496,14496,14496,14496,15072,15072,15072,15072,15648,15648,15648,16224,16224,16224,16224,16992,16992,16992,17568,17568,17568,17568,18144,18144,18144,18144,18824},
								{  144,  328,  504,  680,  872, 1128, 1352, 1544, 1736, 1800, 1992, 2152, 2408, 2600, 2792, 2920, 3112, 3304, 3560, 3688, 3944, 4072, 4200, 4520, 4648, 4840, 5032, 5224, 5480, 5672, 5864, 6056, 6056, 6328, 6584, 6584, 6840, 7096, 7096, 7480, 7736, 7992, 7992, 8248, 8504, 8504, 8760, 9016, 9016, 9272, 9784, 9784, 9784,10168,10168,10552,10552,10936,10936,11320,11320,11832,11832,12216,12216,12216,12576,12576,12960,12960,13344,13344,13920,13920,13920,14496,14496,14496,15072,15072,15072,15648,15648,15648,15648,16224,16224,16224,16992,16992,16992,17568,17568,17568,18144,18144,18144,18144,18824,18824,18824,19592,19592,19592,19592,19592,20360,20360,20360,20360},
								{  176,  376,  584,  776, 1000, 1320, 1544, 1800, 2024, 2088, 2280, 2536, 2728, 2920, 3112, 3368, 3688, 3816, 4072, 4200, 4520, 4648, 4840, 5032, 5224, 5672, 5864, 6056, 6328, 6328, 6584, 6840, 7096, 7352, 7352, 7736, 7992, 8248, 8248, 8504, 8760, 9016, 9272, 9272, 9784, 9784,10168,10168,10552,10552,10936,11320,11320,11832,11832,12216,12216,12576,12576,12960,12960,13344,13344,13920,13920,14496,14496,14496,15072,15072,15072,15648,15648,15648,16224,16224,16992,16992,16992,17568,17568,17568,18144,18144,18144,18824,18824,18824,19592,19592,19592,19592,20360,20360,20360,20360,21128,21128,21128,21128,22152,22152,22152,22920,22920,22920,22920,23688,23688,23688},
								{  208,  440,  680,  904, 1128, 1480, 1768, 2024, 2280, 2344, 2536, 2856, 3112, 3368, 3496, 3816, 4072, 4328, 4584, 4840, 5032, 5224, 5608, 5864, 6056, 6328, 6584, 6840, 7096, 7096, 7352, 7608, 7992, 8248, 8504, 8760, 9016, 9272, 9272, 9656,10168,10168,10552,10552,10936,11320,11320,11704,11832,12216,12576,12576,12960,12960,13344,13344,13728,13920,14496,14496,15072,15072,15072,15648,15648,16224,16224,16224,16800,16800,17568,17568,17568,18144,18144,18824,18824,18824,19592,19592,19592,20360,20360,20360,20360,21128,21128,21128,21896,21896,21896,22920,22920,22920,22920,23688,23688,23688,24456,24456,24456,25456,25456,25456,25456,26096,26096,26096,26096,27056},
								{  224,  488,  744, 1000, 1256, 1704, 1992, 2280, 2600, 2600, 2984, 3240, 3496, 3752, 4072, 4328, 4584, 4840, 5224, 5416, 5608, 6056, 6328, 6584, 6840, 7096, 7352, 7608, 7992, 8248, 8504, 8760, 9016, 9272, 9656, 9656,10168,10552,10552,10936,11320,11320,11704,12216,12216,12576,12960,12960,13344,13728,13728,14496,14496,15072,15072,15648,15648,15648,16224,16224,16800,16800,17568,17568,18144,18144,18144,18824,18824,19592,19592,19592,20360,20360,20360,21128,21128,21128,21896,21896,21896,22920,22920,22920,23688,23688,23688,24456,24456,24456,25456,25456,25456,26096,26096,26096,27056,27056,27056,27056,28336,28336,28336,28336,29296,29296,29296,29296,30256,30256},
								{  256,  552,  840, 1128, 1416, 1896, 2216, 2536, 2920, 2920, 3240, 3624, 3880, 4200, 4456, 4776, 5224, 5416, 5800, 6056, 6328, 6584, 6840, 7352, 7608, 7864, 8248, 8504, 8760, 9016, 9272, 9656,10040,10552,10552,10936,11320,11704,11704,12216,12576,12960,12960,13344,13728,13728,14496,14496,15072,15072,15648,15648,16224,16224,16800,16800,17568,17568,18144,18144,18824,18824,19592,19592,19592,20360,20360,21128,21128,21128,21896,21896,21896,22920,22920,23688,23688,23688,24456,24456,24456,25456,25456,26096,26096,26096,27056,27056,27056,27056,28336,28336,28336,29296,29296,29296,30256,30256,30256,30256,31320,31320,31320,31320,32856,32856,32856,32856,34008,34008},
								{  280,  600,  904, 1224, 1544, 1960, 2408, 2792, 3048, 3176, 3496, 3752, 4136, 4456, 4776, 5224, 5416, 5800, 5992, 6584, 6840, 7096, 7352, 7608, 8120, 8504, 8760, 9016, 9272, 9656,10040,10552,10936,10936,11320,11704,12088,12576,12576,12960,13344,13728,13728,14496,14496,15072,15648,15648,16224,16224,16800,16800,17568,17568,18144,18144,18824,18824,19592,19592,19592,20360,20360,21128,21128,21896,21896,21896,22920,22920,23688,23688,23688,24456,24456,25136,25456,25456,26096,26096,26096,27056,27056,27056,28336,28336,28336,29296,29296,29296,30256,30256,30256,31320,31320,31320,31320,32856,32856,32856,32856,34008,34008,34008,34008,35160,35160,35160,36312,36312},
								{  328,  632,  968, 1288, 1608, 2152, 2536, 2920, 3368, 3368, 3752, 4008, 4456, 4776, 5160, 5416, 5800, 6328, 6584, 6840, 7096, 7608, 7864, 8120, 8504, 9016, 9272, 9656,10040,10552,10552,10936,11320,11704,12088,12576,12960,12960,13344,13728,14304,14304,15072,15072,15648,15648,16224,16800,16800,17376,17376,18144,18144,18824,18824,19592,19592,20360,20360,21128,21128,21128,21896,21896,22920,22920,23688,23688,23688,24456,24456,25136,25136,26096,26096,26096,27056,27056,27056,28336,28336,28336,29296,29296,29296,30256,30256,30256,31320,31320,31320,32856,32856,32856,32856,34008,34008,34008,34008,35160,35160,35160,36312,36312,36312,36312,37440,37440,37440,37440},
								{  336,  696, 1064, 1416, 1800, 2344, 2792, 3176, 3624, 3752, 4136, 4520, 4968, 5352, 5608, 5992, 6456, 6840, 7096, 7608, 7864, 8376, 8760, 9272, 9656,10040,10424,10936,10936,11320,11704,12088,12576,12960,13344,13728,14304,14304,15072,15648,15648,16224,16224,16800,17376,17376,18144,18824,18824,19592,19592,20360,20360,21128,21128,21896,21896,21896,22664,22664,23688,23688,24456,24456,25136,25136,26096,26096,26096,27056,27056,28336,28336,28336,29296,29296,29296,30256,30256,31320,31320,31320,32472,32472,32472,32472,34008,34008,34008,35160,35160,35160,36312,36312,36312,37440,37440,37440,37440,39232,39232,39232,39232,40576,40576,40576,41920,41920,41920,41920},
								{  376,  776, 1160, 1544, 1992, 2600, 3112, 3496, 4072, 4136, 4520, 4968, 5352, 5736, 6328, 6456, 7096, 7608, 7864, 8376, 8632, 9272, 9656,10040,10424,10936,11320,11704,12088,12576,12960,13344,13728,14304,14880,15072,15648,16224,16224,16800,17376,17376,18144,18824,18824,19592,19592,20360,20360,21128,21128,21896,22664,22664,23688,23688,24456,24456,25136,25136,26096,26096,26096,27056,27056,28016,28016,29296,29296,29296,30256,30256,31320,31320,31320,32472,32472,32472,34008,34008,34008,35160,35160,35160,36312,36312,36312,37440,37440,37440,39232,39232,39232,40576,40576,40576,40576,41920,41920,41920,43304,43304,43304,43304,45352,45352,45352,45352,46888,46888},
								{  408,  840, 1288, 1736, 2152, 2856, 3304, 3880, 4328, 4392, 4904, 5352, 5736, 6200, 6712, 7352, 7608, 8120, 8632, 8888, 9656,10040,10424,10808,11320,11704,12088,12960,13344,13728,14304,14304,14880,15648,16224,16224,16800,17376,17952,17952,18568,19592,19592,20360,20360,21128,21896,21896,22664,22664,23688,23688,24456,24456,25136,26096,26096,27056,27056,27056,28016,28016,29296,29296,30256,30256,31320,31320,31320,32472,32472,32472,34008,34008,35160,35160,35160,36312,36312,36312,37440,37440,37440,39232,39232,39232,40576,40576,40576,41920,41920,41920,43304,43304,43304,43304,45352,45352,45352,46888,46888,46888,46888,48424,48424,48424,49872,49872,49872,49872},
								{  440,  904, 1384, 1864, 2344, 3048, 3624, 4200, 4648, 4712, 5352, 5736, 6200, 6712, 7352, 7864, 8376, 8632, 9144, 9656,10424,10808,11192,11704,12088,12960,13344,13728,14304,14880,15648,15648,16224,16800,17376,17952,17952,18568,19592,19592,20360,21128,21128,21896,21896,22664,23432,23432,24456,24456,25136,26096,26096,27056,27056,28016,28016,29296,29296,30256,30256,31320,31320,31320,32472,32472,33624,33624,33624,35160,35160,36312,36312,36312,37440,37440,37440,39232,39232,39232,40576,40576,41920,41920,41920,43304,43304,43304,45352,45352,45352,45352,46888,46888,46888,48424,48424,48424,49872,49872,49872,49872,52176,52176,52176,52176,52176,54480,54480,54480},
								{  488, 1000, 1480, 1992, 2472, 3304, 3880, 4456, 5160, 5096, 5736, 6200, 6712, 7224, 7864, 8376, 8888, 9656,10040,10424,11192,11704,12088,12960,13344,13728,14304,14880,15456,16224,16800,16800,17376,17952,18568,19592,19592,20360,21128,21128,21896,22664,22664,23432,24456,24456,25136,26096,26096,27056,27056,28016,28016,29296,29296,30256,30256,31320,31320,32472,32472,33624,33624,33624,35160,35160,36312,36312,37440,37440,37440,39232,39232,39232,40576,40576,41920,41920,41920,43304,43304,43304,45352,45352,45352,46888,46888,46888,48424,48424,48424,49872,49872,49872,49872,52176,52176,52176,52176,54480,54480,54480,54480,56056,56696,56696,56696,58616,58616,58616},
								{  520, 1064, 1608, 2152, 2664, 3560, 4136, 4776, 5352, 5480, 6200, 6712, 7224, 7864, 8376, 8888, 9528,10040,10808,11192,12088,12576,13344,13728,14304,14880,15456,16224,16800,17376,17952,17952,18568,19336,20360,20360,21128,21896,22664,22664,23432,24456,24456,25136,26096,26096,27056,27056,28016,28976,28976,30256,30256,31320,31320,32472,32472,33624,33624,35160,35160,36312,36312,36312,37440,37440,39232,39232,39232,40576,40576,41920,41920,43304,43304,43304,45352,45352,45352,46888,46888,46888,48424,48424,48424,49872,49872,49872,52176,52176,52176,52176,54480,54480,54480,54480,56056,56056,56056,58616,58616,58616,58616,61176,61176,61176,61176,63072,63072,63072},
								{  552, 1128, 1736, 2280, 2856, 3816, 4456, 5096, 5800, 5864, 6456, 7224, 7736, 8376, 8888, 9528,10424,10808,11576,12088,12960,13344,13728,14304,14880,15456,16224,16800,17376,17952,18568,19336,20104,21128,21128,21896,22664,23432,23432,24456,25136,26096,26096,27056,27056,28016,28976,28976,30256,30256,31320,31320,32472,32472,33624,33624,35160,35160,36312,36312,37440,37440,39232,39232,40576,40576,40576,41920,41920,43304,43304,43304,45352,45352,46888,46888,46888,48424,48424,48424,49872,49872,49872,52176,52176,52176,54480,54480,54480,54480,56056,56056,56056,58616,58616,58616,58616,61176,61176,61176,61176,63072,63072,63072,63072,65888,65888,65888,65888,68040},
								{  584, 1192, 1800, 2408, 2984, 3944, 4712, 5544, 6200, 6120, 6968, 7480, 8248, 8888, 9528,10424,10808,11576,11960,12768,13728,14304,14880,15456,16032,16800,17376,17952,18568,19336,20104,21128,21128,21896,22664,23432,24200,24200,25136,26096,27056,27056,28016,28016,28976,30256,30256,31320,31320,32472,33624,33624,35160,35160,36312,36312,37440,37440,39232,39232,39232,40576,40576,41920,41920,43304,43304,45352,45352,45352,46888,46888,48424,48424,48424,49872,49872,49872,52176,52176,52176,54480,54480,54480,56056,56056,56056,56056,58616,58616,58616,61176,61176,61176,61176,63072,63072,63072,65888,65888,65888,65888,68040,68040,68040,68040,71112,71112,71112,71112},
								{  616, 1256, 1864, 2536, 3112, 4136, 4840, 5736, 6456, 6328, 7224, 7736, 8632, 9144, 9912,10808,11192,11960,12768,13152,14304,14880,15456,16032,16800,17376,17952,18568,19336,20104,21128,21896,21896,22664,23432,24200,25136,26096,26096,27056,28016,28016,28976,30256,30256,31320,31320,32472,33624,33624,34776,35160,36312,36312,37440,37440,39232,39232,40576,40576,41920,41920,43304,43304,43304,45352,45352,46888,46888,46888,48424,48424,49872,49872,49872,52176,52176,52176,54480,54480,54480,56056,56056,56056,58616,58616,58616,58616,61176,61176,61176,63072,63072,63072,65888,65888,65888,65888,68040,68040,68040,68040,71112,71112,71112,71112,73416,73416,73416,76208},
								{  712, 1480, 2216, 2984, 3752, 4200, 4904, 6712, 7608, 7736, 8504, 9016, 9912,10680,11576,12384,13152,14112,14880,15456,16032,17376,17952,18568,19336,20104,20872,21896,22664,23432,24200,25136,26096,27056,27056,28016,28976,29936,30936,30936,32472,32472,33624,34776,34776,36312,37440,37440,39232,39232,40128,40128,41920,43304,43304,43304,45352,45352,46888,46888,48424,48424,49872,49872,52176,52176,52176,54480,54480,56056,56056,56056,58616,58616,58616,58616,61176,61176,61176,63072,63072,63072,65888,65888,65888,68040,68040,68040,71112,71112,71112,73416,73416,73416,76208,76208,76208,78704,78704,80280,80280,80280,80280,80280,80280,80280,80280,80280,80280,80280}};

#if(ENABLE_GUARD_BAND_HARVESTING==0)
// TBS Table with values for control harvesting and higher MCS values.
static const unsigned int tbs_table_scatter_higher_mcs[6][32] = {{21,29,35,45,56,69,83,97,111,129,129,141,165,185,213,237,245,245,269,293,325,357,381,413,445,477,493,517, 525, 541, 565, 605}, // Values for 1.4 MHz BW (6 RBs)
{51,69,85,113,141,173,201,237,277,309,309,349,389,437,509,557,597,597,645,701,791,839,919,983,1047,1111,1191,1239,1447, 1479, 1495, 1511}, // Values for 3 MHz BW
{91,119,145,189,237,293,341,413,461,533,533,581,653,757,855,951,1015,1015,1063,1207,1303,1415,1511,1668,1788,1860,2004,2100,2417, 2449, 2481, 2513}, // Values for 5 MHz BW
{185,241,293,381,485,581,685,823,935,1063,1063,1159,1319,1527,1716,1884,2028,2028,2172,2449,2641,2833,3057,3382,3622,3782,4059,4203,4904, 4960, 4960, 5016}, // Values for 10 MHz BW
{277,365,453,589,717,903,1031,1223,1431,1572,1572,1740,2028,2268,2545,2865,3057,3057,3262,3662,3915,4395,4680,5072,5413,5861,6053,6234,7327, 7567, 7647, 7708}, // Values for 15 MHz BW
{373,485,613,765,967,1175,1383,1644,1884,2124,2124,2353,2641,3057,3382,3782,4107,4107,4395,4904,5240,5861,6234,6810,7327,7647,8236,8505,10035, 10147, 10259, 10371}}; // Values for 20 MHz BW
#else
// TBS Table with values for control harvesting and higher MCS values.
static const unsigned int tbs_table_scatter_higher_mcs[6][32] = {{25,31,41,54,67,83,99,117,133,153,153,169,193,221,249,277,301,301,317,349,389,413,453,485,517,557,589,605, 613, 629, 653, 717}, // Values for 1.4 MHz BW (7 RBs)
{51,69,85,113,141,173,201,237,277,309,309,349,389,437,509,557,597,597,645,701,791,839,919,983,1047,1111,1191,1239,1447, 1479, 1495, 1511}, // Values for 3 MHz BW
{91,119,145,189,237,293,341,413,461,533,533,581,653,757,855,951,1015,1015,1063,1207,1303,1415,1511,1668,1788,1860,2004,2100,2417, 2449, 2481, 2513}, // Values for 5 MHz BW
{185,241,293,381,485,581,685,823,935,1063,1063,1159,1319,1527,1716,1884,2028,2028,2172,2449,2641,2833,3057,3382,3622,3782,4059,4203,4904, 4960, 4960, 5016}, // Values for 10 MHz BW
{277,365,453,589,717,903,1031,1223,1431,1572,1572,1740,2028,2268,2545,2865,3057,3057,3262,3662,3915,4395,4680,5072,5413,5861,6053,6234,7327, 7567, 7647, 7708}, // Values for 15 MHz BW
{373,485,613,765,967,1175,1383,1644,1884,2124,2124,2353,2641,3057,3382,3782,4107,4107,4395,4904,5240,5861,6234,6810,7327,7647,8236,8505,10035, 10147, 10259, 10371}}; // Values for 20 MHz BW
#endif

// TBS Table with standard LTE-based MCS values, i.e., no control harvesting nor higher MCS values.
static const unsigned int tbs_table_std_lte[6][29] = {{19,26,32,41,51,63,75,89,101,117,117,129,149,169,193,217,225,225,241,269,293,325,349,373,405,437,453,469,549}, // Values for 1.4 MHz BW
{49,65,81,109,133,165,193,225,261,293,293,333,373,421,485,533,573,573,621,669,749,807,871,935,999,1063,1143,1191,1383}, // Values for 3 MHz BW
{85,113,137,177,225,277,325,389,437,501,501,549,621,717,807,903,967,967,999,1143,1239,1335,1431,1572,1692,1764,1908,1980,2292}, // Values for 5 MHz BW
{173,225,277,357,453,549,645,775,871,999,999,1095,1239,1431,1620,1764,1908,1908,2052,2292,2481,2673,2865,3182,3422,3542,3822,3963,4587}, // Values for 10 MHz BW
{261,341,421,549,669,839,967,1143,1335,1479,1479,1620,1908,2124,2385,2673,2865,2865,3062,3422,3662,4107,4395,4736,5072,5477,5669,5861,6882}, // Values for 15 MHz BW
{349,453,573,717,903,1095,1287,1527,1764,1980,1980,2196,2481,2865,3182,3542,3822,3822,4107,4587,4904,5477,5861,6378,6882,7167,7708,7972,9422}}; // Values for 20 MHz BW
